package o;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import androidx.annotation.NonNull;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appmarket.framework.startevents.roam.RoamActivityProtocol;
import com.huawei.appmarket.service.alarm.ProSurvivalMessageDealReceiver;
import com.huawei.appmarket.service.contentrecommend.bean.GetPushContentResBean;
import com.huawei.appmarket.service.contentrecommend.bean.GetPushContentResBean$PushContent;

public class dpx extends dpn<Boolean, Boolean> {
    private static volatile long ˏ = 0;

    protected /* synthetic */ Object ˋ(Context context, Object obj) throws InterruptedException {
        return ˎ(context, (Boolean) obj);
    }

    protected /* synthetic */ void ˏ(Context context, Object obj, Object obj2) throws InterruptedException {
        ॱ(context, (Boolean) obj, (Boolean) obj2);
    }

    protected /* synthetic */ Object ॱ(Context context) throws InterruptedException {
        return ˎ(context);
    }

    public dpx() {
        this.ˊ = "BaseRecommendContentTask";
    }

    private static void ˏ() {
        ˏ = System.currentTimeMillis();
    }

    protected Boolean ˎ(Context context) {
        boolean z = true;
        boolean ˊ = doo.ˊ(context);
        long currentTimeMillis = System.currentTimeMillis();
        if (ˊ) {
            if (ˏ == 0) {
                ˏ();
            }
            if (ˏ + 20000 >= currentTimeMillis) {
                z = false;
            }
        }
        if (Logger.ˎ()) {
            Logger.ˏ(this.ˊ, " reachTime=" + z);
        }
        return Boolean.valueOf(z);
    }

    protected Boolean ˎ(Context context, Boolean bool) {
        if (bool == null || !bool.booleanValue()) {
            return Boolean.valueOf(false);
        }
        ˏ();
        ResponseBean ॱ = cfw.ॱ(new dve());
        if (ॱ.getResponseCode() == 0 && ॱ.getRtnCode_() == 0) {
            GetPushContentResBean getPushContentResBean = (GetPushContentResBean) ॱ;
            if (!euf.ˎ().ˏ()) {
                Logger.ˎ(this.ˊ, "push sms flag is false");
                return Boolean.valueOf(true);
            } else if (getPushContentResBean.pushContent_ != null) {
                ˊ(context, getPushContentResBean.phyZone_);
                ॱ(getPushContentResBean);
                ॱ(context, getPushContentResBean);
            } else {
                Logger.ˋ("getPushContent", "pushContent is null");
                if (eqp.ᐝ()) {
                    if (CollectCheck.isEmpty(getPushContentResBean.messages_)) {
                        Logger.ˋ("getPushContent", "messages is emptry");
                    } else {
                        ˋ(getPushContentResBean);
                    }
                }
            }
        }
        return Boolean.valueOf(true);
    }

    protected void ॱ(Context context, Boolean bool, Boolean bool2) {
        if (bool2 != null && bool2.booleanValue()) {
            euf.ˎ().ˎ("lastTime_recommendContent", System.currentTimeMillis());
        }
    }

    private void ˊ(Context context, String str) {
        String ॱ = eua.ˏ().ॱ("physical_address", "");
        if (dof.ˋ(ॱ) || !ॱ.equals(str)) {
            dko o_dko = new dko();
            o_dko.ˏ(20161007);
            dkk.ˊ(ContentManager.getInstant().getContext(), o_dko).ॱ();
            Logger.ˎ(this.ˊ, "clearNotification");
        }
    }

    private void ॱ(GetPushContentResBean getPushContentResBean) {
        RoamDataManager.build().ˎ(getPushContentResBean.mybb_);
        if (getPushContentResBean.roamingTime_ <= 0) {
            long ॱ = eua.ˏ().ॱ("roam_time", 0);
            String ॱ2 = eua.ˏ().ॱ("physical_address", "");
            if (!(ॱ == 0 || dof.ˋ(ॱ2))) {
                eua.ˏ().ʼ(ॱ2 + ॱ);
            }
            eua.ˏ().ʼ("physical_address");
            eua.ˏ().ʼ("roam_time");
            HcridSession.ˋ().ˏ(0);
            HcridSession.ˋ().ˊ("");
        } else {
            eua.ˏ().ˎ("roam_time", getPushContentResBean.roamingTime_);
            HcridSession.ˋ().ˏ(getPushContentResBean.roamingTime_);
        }
        if (!dof.ˋ(getPushContentResBean.phyZone_)) {
            eua.ˏ().ˋ("physical_address", getPushContentResBean.phyZone_);
            HcridSession.ˋ().ˊ(getPushContentResBean.phyZone_);
        }
    }

    public void ॱ(Context context, GetPushContentResBean getPushContentResBean) {
        if (context == null) {
            Logger.ˋ(this.ˊ, "mContext is null");
        } else if (RoamDataManager.build().getAppInfoBean().size() < 3) {
            Logger.ˎ(this.ˊ, "dataSize < 3");
        } else {
            String ॱ = eua.ˏ().ॱ("physical_address", "");
            long ॱ2 = eua.ˏ().ॱ("roam_time", 0);
            if (ॱ2 > 0 && !dof.ˋ(ॱ)) {
                int ॱ3 = eua.ˏ().ॱ(ॱ + ॱ2, 0);
                Logger.ˎ(this.ˊ, "roam page isShow=" + ॱ3);
                if (ॱ3 == 0) {
                    dkk.ˊ(ContentManager.getInstant().getContext(), ˎ(context, getPushContentResBean.pushContent_)).ˎ();
                }
            }
        }
    }

    private void ˋ(GetPushContentResBean getPushContentResBean) {
        Context ˋ = ContentManager.getInstant().getContext();
        GetPushContentResBean$PushContent getPushContentResBean$PushContent = (GetPushContentResBean$PushContent) getPushContentResBean.messages_.get(0);
        dko ˎ = ˎ(ˋ, getPushContentResBean$PushContent);
        String ˋ2 = getPushContentResBean$PushContent.ˋ();
        String ˊ = getPushContentResBean$PushContent.ˊ();
        Intent intent = new Intent(ˋ, ProSurvivalMessageDealReceiver.class);
        intent.putExtra(ProSurvivalMessageDealReceiver.PUSH_MESSAGE_MSGID, ˋ2);
        intent.putExtra(ProSurvivalMessageDealReceiver.PUSH_MESSAGE_DETAILID, ˊ);
        intent.setPackage(ˋ.getPackageName());
        ˎ.ˊ(intent);
        new dpk(ˋ2, ˊ.replaceAll("\\|", "#$#")).onEventNotifyShow(ContentManager.getInstant().getContext());
        new dkk(ContentManager.getInstant().getContext(), ˎ).ˋ();
    }

    @NonNull
    private dko ˎ(Context context, GetPushContentResBean$PushContent getPushContentResBean$PushContent) {
        String ॱ = getPushContentResBean$PushContent.ॱ();
        String ˎ = getPushContentResBean$PushContent.ˎ();
        String ˏ = getPushContentResBean$PushContent.ˏ();
        dko o_dko = new dko();
        o_dko.ˋ(ॱ);
        o_dko.ˊ(ˎ);
        o_dko.ˎ(true);
        o_dko.ˏ(false);
        o_dko.ˊ(ˏ(context));
        o_dko.ˏ(20161007);
        Bitmap bitmap = null;
        if (!dof.ॱ(ˏ)) {
            bitmap = eqx.ˋ(context, ˏ);
        }
        o_dko.ˏ(bitmap);
        return o_dko;
    }

    private Intent ˏ(Context context) {
        cjm o_cjm = new cjm("roam.activity", new RoamActivityProtocol());
        if (!(context instanceof Activity)) {
            o_cjm.ॱ().setFlags(268435456);
        }
        return o_cjm.ॱ(ContentManager.getInstant().getContext());
    }
}
